Skip to content

fix: make install textfile busy#558

Merged
xiaket merged 1 commit intosipeed:mainfrom
zenixls2:fix/ota-textfile-busy
Feb 23, 2026
Merged

fix: make install textfile busy#558
xiaket merged 1 commit intosipeed:mainfrom
zenixls2:fix/ota-textfile-busy

Conversation

@zenixls2
Copy link
Contributor

@zenixls2 zenixls2 commented Feb 21, 2026

📝 Description

make install from bot will get textfile busy message, since it's still running

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

🔗 Related Issue

📚 Technical Context (Skip for Docs)

  • Reference URL:
  • Reasoning:

🧪 Test Environment

  • Hardware:
  • OS:
  • Model/Provider:
  • Channels:

📸 Evidence (Optional)

Click to view Logs/Screenshots

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

Copilot AI review requested due to automatic review settings February 21, 2026 00:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes the "text file busy" error that occurs when running make install while the picoclaw binary is currently running. The solution implements an atomic file replacement pattern using a temporary file and mv, which is a standard approach for replacing executables that may be in use.

Changes:

  • Adds a temporary file suffix variable (INSTALL_TMP_SUFFIX=.new)
  • Modifies the install target to use atomic file replacement (copy to temp → chmod → atomic move)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zenixls2 zenixls2 force-pushed the fix/ota-textfile-busy branch from 18e7fdb to 255ebbb Compare February 21, 2026 01:34
Copilot AI review requested due to automatic review settings February 21, 2026 01:57
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +194 to +227
if err := os.MkdirAll(workspace, 0o755); err != nil {
t.Fatalf("failed to create workspace: %v", err)
}
if err := os.MkdirAll(outsideDir, 0755); err != nil {
if err := os.MkdirAll(outsideDir, 0o755); err != nil {
t.Fatalf("failed to create outside dir: %v", err)
}

tool := NewExecTool(workspace, true)
result := tool.Execute(context.Background(), map[string]interface{}{
result := tool.Execute(context.Background(), map[string]any{
"command": "pwd",
"working_dir": outsideDir,
})

if !result.IsError {
t.Fatalf("expected working_dir outside workspace to be blocked, got output: %s", result.ForLLM)
}
if !strings.Contains(result.ForLLM, "blocked") {
t.Errorf("expected 'blocked' in error, got: %s", result.ForLLM)
}
}

// TestShellTool_WorkingDir_SymlinkEscape verifies that a symlink inside the workspace
// pointing outside cannot be used as working_dir to escape the sandbox.
func TestShellTool_WorkingDir_SymlinkEscape(t *testing.T) {
root := t.TempDir()
workspace := filepath.Join(root, "workspace")
secretDir := filepath.Join(root, "secret")
if err := os.MkdirAll(workspace, 0755); err != nil {
if err := os.MkdirAll(workspace, 0o755); err != nil {
t.Fatalf("failed to create workspace: %v", err)
}
if err := os.MkdirAll(secretDir, 0755); err != nil {
if err := os.MkdirAll(secretDir, 0o755); err != nil {
t.Fatalf("failed to create secret dir: %v", err)
}
os.WriteFile(filepath.Join(secretDir, "secret.txt"), []byte("top secret"), 0644)
os.WriteFile(filepath.Join(secretDir, "secret.txt"), []byte("top secret"), 0o644)
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to shell_test.go (octal literal format and map type alias) appear to be unrelated to the PR's stated purpose of fixing "text file busy" errors during installation. These are code style improvements that should be mentioned in the PR description or submitted as a separate PR. The PR description claims this is a bug fix for the install target, but these test file changes are purely stylistic improvements that don't relate to the installation issue.

Copilot uses AI. Check for mistakes.
@zenixls2 zenixls2 force-pushed the fix/ota-textfile-busy branch from 539ca48 to 2893448 Compare February 21, 2026 17:21
Copy link
Collaborator

@xiaket xiaket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zenixls2 zenixls2 force-pushed the fix/ota-textfile-busy branch 2 times, most recently from 260eae4 to c21042c Compare February 22, 2026 15:27
Copilot AI review requested due to automatic review settings February 22, 2026 15:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mkdir -p $(INSTALL_BIN_DIR)
@cp $(BUILD_DIR)/$(BINARY_NAME) $(INSTALL_BIN_DIR)/$(BINARY_NAME)
@chmod +x $(INSTALL_BIN_DIR)/$(BINARY_NAME)
# Copy binary with temporary suffix to ensure atomic update
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says "Copy binary with temporary suffix to ensure atomic update" but this isn't fully accurate. The atomic update is achieved by the mv -f command on line 106, not just by copying with a temporary suffix. Consider updating the comment to: "Copy binary with temporary suffix, then atomically replace to avoid 'text file busy' error"

Suggested change
# Copy binary with temporary suffix to ensure atomic update
# Copy binary with temporary suffix, then atomically replace to avoid 'text file busy' error

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +24
params map[string]any
result *ToolResult
}

func (m *mockRegistryTool) Name() string { return m.name }
func (m *mockRegistryTool) Description() string { return m.desc }
func (m *mockRegistryTool) Parameters() map[string]interface{} { return m.params }
func (m *mockRegistryTool) Execute(_ context.Context, _ map[string]interface{}) *ToolResult {
func (m *mockRegistryTool) Name() string { return m.name }
func (m *mockRegistryTool) Description() string { return m.desc }
func (m *mockRegistryTool) Parameters() map[string]any { return m.params }
func (m *mockRegistryTool) Execute(_ context.Context, _ map[string]any) *ToolResult {
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to replace interface{} with any in this test file appear unrelated to the PR's stated purpose of fixing the "text file busy" error during installation. While this is a valid code modernization (Go 1.18+ type alias), it should ideally be in a separate PR or the PR description should mention this refactoring.

Copilot uses AI. Check for mistakes.
… to overwrite the file with non-atomic operation
@zenixls2 zenixls2 force-pushed the fix/ota-textfile-busy branch from 8fe7ddd to a2a3571 Compare February 23, 2026 09:15
Copy link
Collaborator

@xiaket xiaket left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@xiaket xiaket merged commit 6d487a1 into sipeed:main Feb 23, 2026
2 checks passed
davidburhans pushed a commit to davidburhans/picoclaw that referenced this pull request Feb 23, 2026
liangzhang-keepmoving pushed a commit to liangzhang-keepmoving/picoclaw that referenced this pull request Mar 2, 2026
hyperwd pushed a commit to hyperwd/picoclaw that referenced this pull request Mar 5, 2026
… to overwrite the file with non-atomic operation (sipeed#558)
renesul pushed a commit to renesul/OK that referenced this pull request Mar 14, 2026
… to overwrite the file with non-atomic operation (sipeed#558)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants